<?php

namespace app\api\library\wechat\getJsapiSign;

use app\api\model\MallWechat;

/**
 *
 * User: chenzheng
 * Date: 2023/5/8
 * Time: 16:09
 */
class V
{
    public static function run($param)
    {
        
        $url          = _checkEmptyParam($param[ 'jumpUrl' ], '跳转路径不能为空');
        $wechatId     = config('env.wechatSchoolId');
        $accessToken  = MallWechat::getAccessToken();
        $jsapi_ticket = MallWechat::getJsapiTiket($wechatId);
        $noncestr     = 'U2FsdGVkX1+2dwIixot7EH8LblUwsOn7DA='; //随机字符串
        $timestamp    = time();
        $str          = "jsapi_ticket={$jsapi_ticket}&noncestr={$noncestr}&timestamp={$timestamp}&url={$url}";
        $sign         = sha1("jsapi_ticket={$jsapi_ticket}&noncestr={$noncestr}&timestamp={$timestamp}&url={$url}");
        $result       = [
            'appId'  => 'wx07556a5ac76abe4e',
            'accessToken'  => $accessToken,
            'noncestr'     => $noncestr,
            'timestamp'    => $timestamp,
            'signature'    => $sign,
            'jsapi_ticket' => $jsapi_ticket,
            'str'          => $str,
        ];
        _outPut(200, $result);
    }
}